package logic_control;

import java.util.Scanner;

public class Fibonacci_1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入n： ");
        int n = scanner.nextInt();
        System.out.println(fibonacci(n));
    }


    public static int fibonacci(int n) {
        int a = 1;
        int b = 1;
        int c = 0;
        if (n == 1 || n == 2) {
            return 1;
        }else {
            for (int i = 0;i < n - 2;i++) {
                c = b;
                b += a;
                a = c;
            }
            return b;
        }

    }
}
